﻿using System.IO;
using System.Linq;
using System.Xml.Linq;

namespace PsqlDotnet.Tests
{
    public class TestBase
    {
        protected static readonly string TestDatabaseName = "test_database";

        public string RootUsername { get; private set; }

        public string Password { get; private set; }

        public FileInfo Psql { get; private set; }

        protected bool ValidatePsql()
        {
            return Psql.Exists;
        }

        public TestBase()
        {
            XDocument doc = XDocument.Load("config.xml");
            RootUsername = doc.Descendants("admin").First().Value;
            Password = doc.Descendants("password").First().Value;
            Psql = new FileInfo(doc.Descendants("psql_path").First().Value);
        }

        protected IPsqlShell CreateShell()
        {
            return new PsqlShell(Psql, RootUsername, Password);
        }
    }
}
